package com.abe.abetest;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;

import com.abe.libbase.base.BaseActivity;

public class AbeFragmentActivity extends BaseActivity {
    private Fragment fragment;

    @Override
    public void init() {
        String fragmentName = getIntent().getStringExtra("fragmentName");
        if (TextUtils.isEmpty(fragmentName)) {
            finish();
        }
        try {
            fragment = (Fragment) (Class.forName(fragmentName).newInstance());
        } catch (Exception e) {
            e.printStackTrace();
            finish();
        }

        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.item_container, fragment).commit();
    }

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_fragment_container;
    }
}